<template>
    <div class="demo1" @touchstart="ts" @touchmove="tc" @touchend="tc" @touchcancel="tc">
        封装长按事件
    </div>
</template>

<script>
export default {
name:"demo",
data(){
    return {
    timerId:null
    }
},
methods:{
    ts(){
        if(this.timerId!=null){
            return;
        }
        //触摸开始
        this.timerId = setTimeout(()=>{
            console.log("你长按了")
        },600)
    },
    tc(){
        clearTimeout(this.timerId);
        this.timerId=null;

    }
}
}
</script>

<style lang="scss" scoped>
.demo1{
    height: 300px;
    border: 1px solid black;
}

</style>
